<template>
  <div style="height: 450px">
    <el-form :model="FIndexObject" label-width="80px">
      <el-form-item label="表名称">
        <el-input
          v-model="FIndexObject.FObjectName"
          ReadOnlyColor
          readonly
        ></el-input>
      </el-form-item>
      <el-form-item label="表类型">
        <el-input
          v-model="FIndexObject.FObjectType"
          ReadOnlyColor
          readonly
        ></el-input>
      </el-form-item>
      <el-form-item label="表描述">
        <el-input
          v-model="FIndexObject.FObjectDescription"
          ReadOnlyColor
          readonly
        ></el-input>
      </el-form-item>
    </el-form>
    <!--  -->
    <el-form :model="FIndexField" label-width="80px">
      <el-form-item label="字段名称">
        <el-input
          v-model="FIndexField.FFieldName"
          ReadOnlyColor
          readonly
        ></el-input>
      </el-form-item>
      <el-form-item label="字段标签">
        <el-input v-model="FIndexField.FFieldCaptoin"></el-input>
      </el-form-item>
      <el-form-item label="字段备注">
        <el-input v-model="FIndexField.FFieldRemark"></el-input>
      </el-form-item>
    </el-form>
    <el-row style="float: right">
      <el-button @click="onSave">保存</el-button>
    </el-row>
  </div>
</template>
<script lang="ts">
import TFormBase from "@/views/BaseForm";
import TDataBaseApi, {
  TDataBaseField,
  TDataBaseObject,
} from "@/baselib/module/database/DataBaseApi";
export default class TFormDataBaseFieldEdit extends TFormBase {
  private FIndexObject: TDataBaseObject = new TDataBaseObject();
  private FIndexField: TDataBaseField = new TDataBaseField();
  public created() {
    let lTemp = this.zContextParams;
    if (lTemp instanceof Object) {
      this.FIndexField = lTemp;
    }
    this.openData();
  }
  private async openData() {
    let lResult = await TDataBaseApi.GetDBObject(this.FIndexField.FObjectID);
    if (!lResult.resultSuccess) {
      this.$myMsgHelp.msgDialog(lResult.resultMsg);
      return;
    }
    let lResultB = await TDataBaseApi.GetDBField(this.FIndexField.FFieldID);
    if (!lResultB.resultSuccess) {
      this.$myMsgHelp.msgDialog(lResultB.resultMsg);
      return;
    }
    this.FIndexObject = lResult.resultData;
    this.FIndexField = lResultB.resultData;
  }
  private async onSave() {
    let lResult = await TDataBaseApi.SaveDBField(this.FIndexField);
    if (!lResult.resultSuccess) {
      this.$myMsgHelp.msgDialog(lResult.resultMsg);
      return;
    }
    if (typeof this.zContextOnCall == "function") {
      this.zContextOnCall("save", this.FIndexField);
    }
  }
}
</script>